import React, { Component, PureComponent } from 'react';
/* 
  1. PureComponent
*/

class Demo extends PureComponent{

  render(){
    console.log("Demo 组件更新了");
    return <div>
      <h1>Demo 组件 {this.props.msg}</h1>
    </div>
  }
}

class App extends Component {
  state = {
    num:1
  }
  render() {
    return (
      <div>
        <Demo msg="demo"></Demo>
        <button onClick={()=>{
          this.setState(()=>{
            return {
              num: this.state.num +1 
            }
          })
        }}>加{this.state.num}</button>
      </div>
    );
  }
}

export default App;
